import Vue from 'vue'
import Vuex from 'vuex'
import root from './modules/root'
// 引入vuex持久化
import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)
const createStorage = createPersistedState({
  storage: window.sessionStorage,
  reducer: vuexState => {
    let sessionState = Object.assign({}, vuexState)
    return sessionState
  },
})

export default new Vuex.Store({
  ...root,
  plugins: [createStorage],
})
